package com.day9;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class zy1 {
    public static void main(String[] args) {
        Comparator<Student3> cc = new Comparator<Student3>() {
            @Override
            public int compare(Student3 o1, Student3 o2) {
                int a = o1.getName().compareTo(o2.getName());
                a = a == 0 ? o1.getAge() - o2.getAge() : a;
                return a;
            }
        };
        TreeMap<Student3, String> tm = new TreeMap<>(cc);

        Student3 st1 = new Student3("zhangsan", 23);
        Student3 st2 = new Student3("lisi", 25);
        Student3 st3 = new Student3("zhangsan", 23);
        Student3 st4 = new Student3("wangwu", 23);
        tm.put(st1, "邵阳");
        tm.put(st2, "邵东");
        tm.put(st3, "湖南");
        tm.put(st4, "荷兰");

        tm.forEach((Student3 key, String vult) -> {
            System.out.println(key + ":" + vult);
        });

    }
}
